
package edu.gatech.stolen.tea;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * 
 * A holder for each ToDoItem, it is empty when first created.
 * The default: Name:name, category:All, description:none, location:n\a, dueDate:now, 
 * status:false
 * @author Leshi
 *
 */
public class ToDoItem implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 4L;
	private String name;
	private String category;
	private String description;
	private String location;
	private Date dateGiven = new Date();;
	private Date dueDate;
	private boolean status;
	
	
	public ToDoItem() {
		
		name="name";
		category="All";
		description="none";
		location="n/a";
		dueDate=new Date();
		status=false;
		
		
	}
	
	/**
	 * gets the name of the item held by this specific ToDoItem
	 */
	public String getName() {
		
		return name;
		
	}
	
	/**
	 * sets the name of the item held by this specific ToDoItem
	 */
	public void setName(String name) {
		
		this.name = name;
		
	}
	
	/**
	 * gets the description of the item held by this specific ToDoItem
	 */
	public String getDescription() {
		
		return description;
		
	}
	
	/**
	 * sets the description of the item held by this specific ToDoItem
	 */
	public void setDescription(String description) {
		
		this.description = description;
		
	}
	
	/**
	 * gets the location that the user must go to to do the item held by this specific ToDoItem
	 */
	public String getLocation() {
		
		return location;
		
	}
	
	/**
	 * sets the location that the user must go to to do the item held by this specific ToDoItem
	 */
	public void setLocation(String location) {
		
		this.location = location;
		
	}
	
	/**
	 * gets the date that the item held by this specific ToDoItem was given to user
	 */
	public String getDateGiven() {
		DateFormat df1 = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
		String dateGivenStr = df1.format(dateGiven);	
		return dateGivenStr;
		
	}
	
	/**
	 * set the start date
	 * @param dG
	 */
	public void setDateGiven(String dG) {
		SimpleDateFormat sdf = new SimpleDateFormat( "MM/dd/yyyy hh:mm" );
		try {
			Date dateGiven = sdf.parse(dG);
			this.dateGiven = dateGiven;
		} catch (ParseException e) {
			//System.out.println("Unable to parse " + dueDate);
			e.printStackTrace();
		}
		
	}
	
	/**
	 * get a string representation of the due date
	 */
	public String getDueDate() {
		SimpleDateFormat sdf = new SimpleDateFormat( "MM/dd/yyyy hh:mm" );
		return sdf.format(dueDate);
		
	}
	
	/**
	 * 
	 * @param dueDate
	 */
	public void setDueDate(String dueDate) {
		SimpleDateFormat sdf = new SimpleDateFormat( "MM/dd/yyyy hh:mm" );
		try {
			Date dueD = sdf.parse(dueDate);
			this.dueDate = dueD;
		} catch (ParseException e) {
			//System.out.println("Unable to parse " + dueDate);
			e.printStackTrace();
		}
		
		
	}
	
	/**
	 * sets the category of which this item belongs to
	 */
	public void setCategory(String category){
		this.category=category;
	}
	
	/**
	 * gets the category of which this item belongs to
	 */
	public String getCategory(){
		return category;
	}
	
	/**
	 * the status of this item complete/incomplete
	 */
	public boolean getStatus(){
		return status;
	}
	
	/**
	 * set the status of this item complete/incomplete
	 */
	public void setStatus(boolean status){
		this.status=status;
	}

	
}
